<%-- 
    Document   : carModelManage
    Created on : Aug 31, 2011, 8:50:21 PM
    Author     : HIEP
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<script>
    function validCarType(){
        var name = document.forms["CarTypes"]["name"].value;
        
        if(name =="" || name == null){
            alert("Please enter name of Car Type!");
            return false;
        }
        return true;
    }
    
    function confirmDelete(){
        return confirm("Are you sure want delete?");
    }    
</script>

<!DOCTYPE html>
<div id="content" class="roundedBorders">
    <!-- Title -->
    <div id="title" class="b2">
        <h2>Manage CarTypes</h2>
    </div>
    <!-- Title -->
    <!-- Inner Content -->
    <div id="innerContent">
        <c:if test="${item == null}">
            <!-- Form -->
            <html:form onsubmit="return validCarType();" action="/CarTypeAction.do?method=add" method="POST">
                <div class="fieldset fieldsetBlock active tabs">
                    <div class="header">
                        <h3>Add New Car Type</h3>
                    </div>
                    <div class="tabs">
                        <fieldset id="fieldset1" >
                            <legend>Post content</legend>
                            <div class="field required">
                                <label>Name</label> 
                                <html:text styleClass="text" property="name" value=""/>
                                <span class="required-icon tooltip" title=" This field is required, it cannot be blank.">Required</span> 
                            </div>
                            <div id="buttom1">
                                <strong>
                                    <html:submit value="Add" styleClass="buttom_form"/>
                                </strong>
                                <strong>    
                                    <html:reset value="Reset" styleClass="buttom_form"/>
                                </strong>
                            </div>
                        </fieldset>
                    </div>
                    <span class="bBR"></span>
                </div>
            </html:form>
            <!-- /Form -->
        </c:if>
        <c:if test="${item != null}">
            <!-- Form -->
            <html:form onsubmit="return validCarType();" action="/CarTypeAction.do?method=update" method="POST">
                <div class="fieldset fieldsetBlock active tabs">
                    <div class="header">
                        <h3>Edit Car Type</h3>
                    </div>
                    <div class="tabs">
                        <fieldset id="fieldset1" >
                            <legend>Post content</legend>
                            <input hidden="true" value="${item.id}" type="hidden" name="id"/>
                            <div class="field required">
                                <label>Name</label> 
                                <input type="text" class="text" name="name" id="name" value="${item.name}"/> 
                                <span class="required-icon tooltip" title=" This field is required, it cannot be blank.">Required</span> 
                            </div>
                            <div id="buttom1">
                                <strong>
                                    <html:submit value="Update" styleClass="buttom_form"/>
                                </strong>
                                <strong>    
                                    <html:cancel value="Cancel" styleClass="buttom_form"/>
                                </strong>
                            </div>
                        </fieldset>
                    </div>
                    <span class="bBR"></span>
                </div>
            </html:form>
            <!-- /Form -->
        </c:if>	
        <!-- ListTable -->
        <table cellspacing="0" class="listTable" id="postList">
            <!-- Thead -->
            <thead>
                <tr>
                    <th class="first"><div></div></th>
            <th><a href="#" title="Post">Name</a></th>
            <th class="last"a colspan="2"><a href="#" title="Date">Action</a></th>
            </tr>
            </thead>
            <!-- /Thead -->
            <!-- Tfoot -->
            <tfoot>
                <tr>
                    <td colspan="5">
                        <div class="inner">
                            <div class="paginate">
                            </div>
                        </div>
                    </td>
                </tr>
            </tfoot>
            <!-- /Tfoot -->
            <!-- Tbody -->
            <tbody>
                <c:if test="${list != null}">
                    <c:forEach items="${list}" var="type">
                        <tr>
                            <td><input type="checkbox" class="checkbox"/></td>
                            <td>${type.name}</td>
                            <td><html:link action="/CarTypeAction.do?method=edit&id=${type.id}">Edit</html:link></td>
                                <td class="last">
                                <html:link onclick="return confirmDelete();" action="/CarTypeAction.do?method=delete&id=${type.id}">Delete</html:link>
                                </td>
                            </tr>
                    </c:forEach>
                </c:if>

            </tbody>
            <!-- /Tbody -->
        </table>
        <!-- /ListTable -->
    </div>
    <!-- /Inner Content -->
    <div class="bBottom"><div></div></div>
</div>